package cn.anlucky.apiadmin.config;

import cn.anlucky.apiadmin.service.UserRoleService;
import cn.dev33.satoken.stp.StpInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class AuthConfig implements StpInterface {

    @Autowired
    private UserRoleService userRoleService;

    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        return null;
    }


    /**
     * 取用户的角色
     * @param loginId
     * @param loginType
     * @return
     */
    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        // 取当前用户的角色列表
        List<String> userRoleList = userRoleService.getUserRoleByUserId(Integer.parseInt(loginId.toString()));
        return userRoleList;
    }
}
